#include "../../common/message.hpp"
#include "../../common/net.hpp"

void onMessage(const rpc::BaseConnection::ptr& conn,rpc::BaseMessage::ptr & msg)
{
    std::string body = msg->serialize();
    std::cout<<body<<std::endl;
    rpc::RpcResponse::ptr rpc_req = rpc::MessageFactory::create<rpc::RpcResponse>();
    rpc_req->setId(rpc::UUID::uuid());
    rpc_req->setMType(rpc::MType::RSP_RPC);
    rpc_req->setRCode(rpc::RCode::RCODE_OK);
    rpc_req->setResult(33);
    conn->send(rpc_req);
}

int main()
{
    rpc::BaseServer::ptr server = rpc::ServerFactory::create(9090);
    server->setMessageCallback(onMessage);
    server->start();
    return 0;
}

